﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CompositePattern.DemoOne
{
    public class Root : IRoot
    {
        private List<object> subordinateList = new List<object>();
        private string name = "";
        private string position = "";
        private int salary = 0;

        public Root(string name, string position, int salary)
        {
            this.name = name;
            this.position = position;
            this.salary = salary;
        }

        public void add(ILeaf leaf)
        {
            this.subordinateList.Add(leaf);
        }

        public void add(IBranch branch)
        {
            this.subordinateList.Add(branch);
        }

        public string getInfo()
        {
            string info = string.Empty;
            info = "name:" + this.name + Environment.NewLine;
            info += "position:" + this.position + Environment.NewLine;//职位
            info += "salary:" + this.salary + Environment.NewLine; //薪水
            return info;
        }

        public List<object> getSubordinateInfo()
        {
            return this.subordinateList;
        }
    }
}
